<html>
<head><meta charset="utf-8"><title>truly parallel codegen · t-compiler/wg-parallel-rustc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/index.html">t-compiler/wg-parallel-rustc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html">truly parallel codegen</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177177208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177208">(Oct 02 2019 at 18:15)</a>:</h4>
<p>I think we touched on this briefly durning the planning meeting last time, but parallel rustc should enable us to actually enable truly parallel codegen for all cgus I think</p>



<a name="177177232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177232">(Oct 02 2019 at 18:15)</a>:</h4>
<p>where right now we codegen every CGU sequentially and then fork it off into the background to actually get llvm codegen'd</p>



<a name="177177237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177237">(Oct 02 2019 at 18:15)</a>:</h4>
<p>or well I should say truly parallel translation to LLVM IR, not codegen</p>



<a name="177177275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177275">(Oct 02 2019 at 18:15)</a>:</h4>
<p>My impression based on the comments in the codegen crates was that LLVM itself doesn't let us do that? Was that incorrect?</p>



<a name="177177334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177334">(Oct 02 2019 at 18:16)</a>:</h4>
<p>nah we can invoke LLVM in parallel as much as we like</p>



<a name="177177335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177335">(Oct 02 2019 at 18:16)</a>:</h4>
<p>Do we just not do it today because the compiler itself can't codegen in parallel since queries etc are single threaded?</p>



<a name="177177341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177341">(Oct 02 2019 at 18:16)</a>:</h4>
<p>we do that today for actual codegen/optimization</p>



<a name="177177352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177352">(Oct 02 2019 at 18:16)</a>:</h4>
<p>the only reason we don't translate to LLVM in parallel is that rustc's data structures don't support it</p>



<a name="177177363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177363">(Oct 02 2019 at 18:16)</a>:</h4>
<p>but this could be a pretty huge win for a parallel compiler</p>



<a name="177177367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177367">(Oct 02 2019 at 18:16)</a>:</h4>
<p>yeah, I somehow thought that LLVM did not support parallel 'IR creation'</p>



<a name="177177379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177379">(Oct 02 2019 at 18:16)</a>:</h4>
<p>because translation to IR is such a hgue time chunk in both debug and release builds</p>



<a name="177177380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177380">(Oct 02 2019 at 18:16)</a>:</h4>
<p>but yeah that sounds like a big win compared to today, maybe even the "ticket" so to speak</p>



<a name="177177399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177399">(Oct 02 2019 at 18:17)</a>:</h4>
<p>it would also, I think, radically simplify the backend</p>



<a name="177177417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177417">(Oct 02 2019 at 18:17)</a>:</h4>
<p>right now there's all this crazy jobserver stuff and threads flying around, but truly being parallel here would make things quite a bit easier</p>



<a name="177177433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177433">(Oct 02 2019 at 18:17)</a>:</h4>
<p>it is also a major departure from what we do today</p>



<a name="177177450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177450">(Oct 02 2019 at 18:17)</a>:</h4>
<p>so we wouldn't be able to capitalize on it until parallel compilation lands</p>



<a name="177177514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177514">(Oct 02 2019 at 18:18)</a>:</h4>
<p>but I think this is something we'll want to keep in mind, is that 100% parallel translation to LLVM IR is a win we have not actually unlocked yet</p>



<a name="177177523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177523">(Oct 02 2019 at 18:18)</a>:</h4>
<p>even if parallel rustc is built</p>



<a name="177177563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177563">(Oct 02 2019 at 18:18)</a>:</h4>
<p>indeed, yes -- so you think it's not viable to sort of have both at the same time? i.e., how we do with queries elsewhere?</p>



<a name="177177734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177734">(Oct 02 2019 at 18:20)</a>:</h4>
<p>well it's not really both at the same time</p>



<a name="177177747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177747">(Oct 02 2019 at 18:20)</a>:</h4>
<p>it's more of that rustc will at some point determine "here's N codegen units"</p>



<a name="177177775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177775">(Oct 02 2019 at 18:21)</a>:</h4>
<p>today we have this complicated way of one thread translates all N units to LLVM IR and then forks off work to background crates for codegen/optimization</p>



<a name="177177799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177799">(Oct 02 2019 at 18:21)</a>:</h4>
<p>whereas with a truly parallel rustc we can simply, like with rayon, have a "parallel for loop"</p>



<a name="177177825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177825">(Oct 02 2019 at 18:21)</a>:</h4>
<p>where we just translate to llvm ir, immediately optimize/codegen, and then go further</p>



<a name="177177839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177839">(Oct 02 2019 at 18:21)</a>:</h4>
<p>writing the synchronization point for LTO and/or ThinLTO would also be almost trivial</p>



<a name="177177858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177858">(Oct 02 2019 at 18:21)</a>:</h4>
<p>since you'd just wait for all codegen to be done, link everything, and then spin up another parallel for loop</p>



<a name="177177914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177914">(Oct 02 2019 at 18:22)</a>:</h4>
<p>there's a lot of complication today due to the inherent architecture</p>



<a name="177177921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177921">(Oct 02 2019 at 18:22)</a>:</h4>
<p>where you can't share rustc data structures across threads</p>



<a name="177177944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177944">(Oct 02 2019 at 18:22)</a>:</h4>
<p>but if we lift that restriction then all of a sudden we can write most of the translation backend in a much more natural way</p>



<a name="177177988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177177988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177177988">(Oct 02 2019 at 18:23)</a>:</h4>
<p>Do we not already have that loop today though that could be "optionally parallel"?</p>



<a name="177178009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177178009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177178009">(Oct 02 2019 at 18:23)</a>:</h4>
<p>Similar to how the rest of the compiler is written</p>



<a name="177185248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177185248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177185248">(Oct 02 2019 at 19:47)</a>:</h4>
<p>hey sorry went away into a meeting</p>



<a name="177185267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177185267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177185267">(Oct 02 2019 at 19:47)</a>:</h4>
<p>we don't have a straightforward loop for codegen, no</p>



<a name="177185331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177185331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177185331">(Oct 02 2019 at 19:48)</a>:</h4>
<p>we have this -- <a href="https://github.com/rust-lang/rust/blob/f2023ac599c38a59f86552089e6791c5a73412d3/src/librustc_codegen_ssa/back/write.rs#L1059-L1193" target="_blank" title="https://github.com/rust-lang/rust/blob/f2023ac599c38a59f86552089e6791c5a73412d3/src/librustc_codegen_ssa/back/write.rs#L1059-L1193">https://github.com/rust-lang/rust/blob/f2023ac599c38a59f86552089e6791c5a73412d3/src/librustc_codegen_ssa/back/write.rs#L1059-L1193</a></p>



<a name="177185343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177185343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177185343">(Oct 02 2019 at 19:48)</a>:</h4>
<p>it tries to balance work between the main thread and other threads</p>



<a name="177185353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177185353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177185353">(Oct 02 2019 at 19:48)</a>:</h4>
<p>it gets significantly more complicated when most work is parallel but some work has to stick to one thread</p>



<a name="177189046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177189046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177189046">(Oct 02 2019 at 20:26)</a>:</h4>
<p>yeah, that makes sense -- bit unfortunate that we don't have executors out there that already enable this, via two separate buckets of both Send tasks and non-Send tasks</p>



<a name="177189072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177189072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177189072">(Oct 02 2019 at 20:27)</a>:</h4>
<p>though we probably know enough extra information that it wouldn't be ideal to just use an off the shelf solution even if it existed</p>



<a name="177191914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177191914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177191914">(Oct 02 2019 at 20:58)</a>:</h4>
<blockquote>
<p>but I think this is something we'll want to keep in mind, is that 100% parallel translation to LLVM IR is a win we have not actually unlocked yet</p>
</blockquote>
<p>interesting!</p>



<a name="177543616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177543616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177543616">(Oct 07 2019 at 17:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116015">@Alex Crichton</span> I think this is definitely a goal -- the one major thing we have to be careful about I think is that we don't want to have too many LLVM modules created all at once, just to keep memory usage down.</p>



<a name="177543629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177543629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177543629">(Oct 07 2019 at 17:56)</a>:</h4>
<p>but I think that the existing parallel compilation stuff totally supports this already</p>



<a name="177543632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177543632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177543632">(Oct 07 2019 at 17:56)</a>:</h4>
<p>or am I missing something?</p>



<a name="177565868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565868">(Oct 07 2019 at 22:12)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> right yeah, but I think the jobserver plus rearchitecting things would basically fix that</p>



<a name="177565885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565885">(Oct 07 2019 at 22:13)</a>:</h4>
<p>today we have one thread, which if it runs as fast as possible, generates all llvm modules</p>



<a name="177565895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565895">(Oct 07 2019 at 22:13)</a>:</h4>
<p>and then those llvm modules sit idle in memory while we wait for parallelism to come optimize/codegen them</p>



<a name="177565905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565905">(Oct 07 2019 at 22:13)</a>:</h4>
<p>if we instead used one token at a time to take an entire llvm module through to completion</p>



<a name="177565916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565916">(Oct 07 2019 at 22:13)</a>:</h4>
<p>for example you translate to llvm ir, then immediately optimized, then immediately codegen</p>



<a name="177565922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565922">(Oct 07 2019 at 22:13)</a>:</h4>
<p>that would be the same solution we have now of trading off who does what</p>



<a name="177565985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177565985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177565985">(Oct 07 2019 at 22:14)</a>:</h4>
<p>this, I think, is definitely an area of complexity that would simply "go away" if we switch to truly parallel codegen governed by a jobserver</p>



<a name="177566058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177566058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177566058">(Oct 07 2019 at 22:15)</a>:</h4>
<p>currently we have to rate limit the main thread to stop codegen'ing and switch to optimizing to avoid producing too many llvm modules sitting in memory</p>



<a name="177566065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/truly%20parallel%20codegen/near/177566065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/truly.20parallel.20codegen.html#177566065">(Oct 07 2019 at 22:15)</a>:</h4>
<p>but with truly parallel codegen no rate limiting is needed since we take an llvm module through to completion each time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>